//: Playground - noun: a place where people can play

import UIKit

var str = "Hello, playground"


//:swift整数，浮点数，bool，数组，字典中的所有基本类型都是值类型


//String可以通过将Character值数组作为参数传递给其初始化程序来构造值
let catCharacters:[Character] = ["C","a","t","!","🐱"]
let catString = String(catCharacters)
print(catString)



let greeting = "Gutan Tag!"
greeting[greeting.startIndex]
greeting[greeting.index(before: greeting.endIndex)]
greeting[greeting.index(after: greeting.startIndex)]
let index = greeting.index(greeting.startIndex, offsetBy: 7)
greeting[index]

//尝试访问字符串范围Character之外的索引或字符串范围之外的索引将触发运行时错误。
//greeting[greeting.endIndex] // Error
//greeting.index(after: greeting.endIndex) // Error


